<?php

/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
class Badge_Widget_ListAwardsController extends Engine_Content_Widget_Abstract
{

  public function indexAction()
  {
  	
    // Don't render this if not authorized
    $viewer = Engine_Api::_()->user()->getViewer();


    $params = array(
      'order' => $this->_getParam('order','recent'),
      'limit' => $this->_getParam('max', 5),
    );

    $keys = array('badge', 'user', 'featured');
    foreach ($keys as $key) {
      $val = $this->_getParam($key);
      if (strlen($val)) {
        $params[$key] = $val;
      }
    }
    
    
    
    $this->view->paginator = $paginator = Engine_Api::_()->badge()->getAwardsPaginator($params);
    
    // Do not render if nothing to show
    if( $paginator->getTotalItemCount() <= 0 ) {
      return $this->setNoRender();
    }

    $this->view->display_style = $this->_getParam('display_style', 'narrow');
    $this->view->showphoto = $this->_getParam('showphoto', 1);
    $this->view->showbadge = $this->_getParam('showbadge', 1);
    $this->view->showdetails = $this->_getParam('showdetails', 1); 
    
  }

}